{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import  numpy as np\n",
    "import pandas as pd\n",
    "import talib as ta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = np.arange(100)\n",
    "s = pd.Series(a)\n",
    "i = np.random.randint(0, 99)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,\n",
       "       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n",
       "       34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,\n",
       "       51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,\n",
       "       68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,\n",
       "       85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      0\n",
       "1      1\n",
       "2      2\n",
       "3      3\n",
       "4      4\n",
       "      ..\n",
       "95    95\n",
       "96    96\n",
       "97    97\n",
       "98    98\n",
       "99    99\n",
       "Length: 100, dtype: int32"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "75"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "80.9 ns ± 1.68 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit a[i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7.58 µs ± 125 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit s[i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-12-28</td>\n",
       "      <td>9.72</td>\n",
       "      <td>9.95</td>\n",
       "      <td>9.71</td>\n",
       "      <td>9.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2019-01-02</td>\n",
       "      <td>9.74</td>\n",
       "      <td>9.79</td>\n",
       "      <td>9.58</td>\n",
       "      <td>9.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2019-01-03</td>\n",
       "      <td>9.70</td>\n",
       "      <td>9.82</td>\n",
       "      <td>9.66</td>\n",
       "      <td>9.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2019-01-04</td>\n",
       "      <td>9.73</td>\n",
       "      <td>10.00</td>\n",
       "      <td>9.70</td>\n",
       "      <td>9.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2019-01-07</td>\n",
       "      <td>10.09</td>\n",
       "      <td>10.09</td>\n",
       "      <td>9.92</td>\n",
       "      <td>9.98</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         date   open   high   low  close\n",
       "0  2018-12-28   9.72   9.95  9.71   9.80\n",
       "1  2019-01-02   9.74   9.79  9.58   9.70\n",
       "2  2019-01-03   9.70   9.82  9.66   9.81\n",
       "3  2019-01-04   9.73  10.00  9.70   9.96\n",
       "4  2019-01-07  10.09  10.09  9.92   9.98"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import tushare as ts\n",
    "\n",
    "df_in = ts.get_k_data('600000')\n",
    "df = df_in[['date','open','high','low','close']].copy()\n",
    "df = df.iloc[0:100,:]\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>code</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-12-28</td>\n",
       "      <td>9.72</td>\n",
       "      <td>9.80</td>\n",
       "      <td>9.95</td>\n",
       "      <td>9.71</td>\n",
       "      <td>274040.0</td>\n",
       "      <td>600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2019-01-02</td>\n",
       "      <td>9.74</td>\n",
       "      <td>9.70</td>\n",
       "      <td>9.79</td>\n",
       "      <td>9.58</td>\n",
       "      <td>237628.0</td>\n",
       "      <td>600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2019-01-03</td>\n",
       "      <td>9.70</td>\n",
       "      <td>9.81</td>\n",
       "      <td>9.82</td>\n",
       "      <td>9.66</td>\n",
       "      <td>186542.0</td>\n",
       "      <td>600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2019-01-04</td>\n",
       "      <td>9.73</td>\n",
       "      <td>9.96</td>\n",
       "      <td>10.00</td>\n",
       "      <td>9.70</td>\n",
       "      <td>271728.0</td>\n",
       "      <td>600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2019-01-07</td>\n",
       "      <td>10.09</td>\n",
       "      <td>9.98</td>\n",
       "      <td>10.09</td>\n",
       "      <td>9.92</td>\n",
       "      <td>235973.0</td>\n",
       "      <td>600000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         date   open  close   high   low    volume    code\n",
       "0  2018-12-28   9.72   9.80   9.95  9.71  274040.0  600000\n",
       "1  2019-01-02   9.74   9.70   9.79  9.58  237628.0  600000\n",
       "2  2019-01-03   9.70   9.81   9.82  9.66  186542.0  600000\n",
       "3  2019-01-04   9.73   9.96  10.00  9.70  271728.0  600000\n",
       "4  2019-01-07  10.09   9.98  10.09  9.92  235973.0  600000"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_in.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "open = df.open.values\n",
    "high = df.high.values\n",
    "low = df.low.values\n",
    "close = df.close.values\n",
    "\n",
    "n = len(close)\n",
    "\n",
    "L1 = 3\n",
    "L2 = 7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "import talib as ta\n",
    "\n",
    "ma1 = ta.SMA(df.close.values, timeperiod=L1)\n",
    "ma2 = ta.SMA(df.close.values, timeperiod=L2)\n",
    "\n",
    "con_long = ma1 > ma2\n",
    "con_short = ma1 < ma2\n",
    "\n",
    "trend = np.zeros(n)\n",
    "\n",
    "trend[con_long] = 1\n",
    "trend[con_short] = -1\n",
    "\n",
    "sig = np.zeros(n)\n",
    "pos = np.zeros(n)\n",
    "#新仓位的开仓价\n",
    "pce = np.zeros(n)\n",
    "\n",
    "#保存交易信息\n",
    "trade_info = [\"\" for i in range(n)]\n",
    "\n",
    "#每次开仓一手\n",
    "new_pos = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(L2, n):\n",
    "    # 仓位不变\n",
    "    pos[i] = pos[i-1]\n",
    "    \n",
    "    # 昨天收盘， 出现多头趋势，开盘开多仓， 有空头就平掉\n",
    "    if trend[i - 1] > 0 and pos[i - 1] <= 0:\n",
    "        pos[i] = new_pos\n",
    "        \n",
    "        sig[i] = new_pos-pos[i-1]\n",
    "        \n",
    "        pce[i] = open[i]\n",
    "        \n",
    "        trade_info[i] = u'long at %s' % pce[i]\n",
    "    elif trend[i - 1] < 0 and pos[i-1] >= 0:\n",
    "        pos[i] = -new_pos\n",
    "        \n",
    "        sig[i] = -new_pos-pos[i-1]\n",
    "        \n",
    "        pce[i] = open[i]\n",
    "        \n",
    "        trade_info[i] = u'short at %s' % (pce[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pos</th>\n",
       "      <th>close</th>\n",
       "      <th>pce</th>\n",
       "      <th>trend_info</th>\n",
       "      <th>open</th>\n",
       "      <th>ma2</th>\n",
       "      <th>ma1</th>\n",
       "      <th>sig</th>\n",
       "      <th>low</th>\n",
       "      <th>high</th>\n",
       "      <th>trend</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.80</td>\n",
       "      <td>0.0</td>\n",
       "      <td></td>\n",
       "      <td>9.72</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.71</td>\n",
       "      <td>9.95</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.70</td>\n",
       "      <td>0.0</td>\n",
       "      <td></td>\n",
       "      <td>9.74</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.58</td>\n",
       "      <td>9.79</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.81</td>\n",
       "      <td>0.0</td>\n",
       "      <td></td>\n",
       "      <td>9.70</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.770000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.66</td>\n",
       "      <td>9.82</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.96</td>\n",
       "      <td>0.0</td>\n",
       "      <td></td>\n",
       "      <td>9.73</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.823333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.70</td>\n",
       "      <td>10.00</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.98</td>\n",
       "      <td>0.0</td>\n",
       "      <td></td>\n",
       "      <td>10.09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.916667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.92</td>\n",
       "      <td>10.09</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   pos  close  pce trend_info   open  ma2       ma1  sig   low   high  trend\n",
       "0  0.0   9.80  0.0              9.72  NaN       NaN  0.0  9.71   9.95    0.0\n",
       "1  0.0   9.70  0.0              9.74  NaN       NaN  0.0  9.58   9.79    0.0\n",
       "2  0.0   9.81  0.0              9.70  NaN  9.770000  0.0  9.66   9.82    0.0\n",
       "3  0.0   9.96  0.0              9.73  NaN  9.823333  0.0  9.70  10.00    0.0\n",
       "4  0.0   9.98  0.0             10.09  NaN  9.916667  0.0  9.92  10.09    0.0"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame({'open':open,'high':high,'low':low,'close':close,\n",
    "                  'ma1':ma1, 'ma2':ma2,'trend':trend, 'sig':sig,\n",
    "                  'pce':pce,'pos':pos,'trend_info':trade_info}, columns={'open','high','low','close','ma1', 'ma2','trend','sig','pos', 'pce','trend_info'})\n",
    "\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pos</th>\n",
       "      <th>close</th>\n",
       "      <th>pce</th>\n",
       "      <th>trend_info</th>\n",
       "      <th>open</th>\n",
       "      <th>ma2</th>\n",
       "      <th>ma1</th>\n",
       "      <th>sig</th>\n",
       "      <th>low</th>\n",
       "      <th>high</th>\n",
       "      <th>trend</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.80</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>9.72</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.71</td>\n",
       "      <td>9.95</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.70</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>9.74</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.58</td>\n",
       "      <td>9.79</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.81</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>9.70</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.770000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.66</td>\n",
       "      <td>9.82</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.96</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>9.73</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.823333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.70</td>\n",
       "      <td>10.00</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.0</td>\n",
       "      <td>9.98</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>10.09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.916667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.92</td>\n",
       "      <td>10.09</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>11.22</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>11.09</td>\n",
       "      <td>11.212857</td>\n",
       "      <td>11.143333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.96</td>\n",
       "      <td>11.26</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>11.29</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>11.19</td>\n",
       "      <td>11.220000</td>\n",
       "      <td>11.206667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.02</td>\n",
       "      <td>11.30</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>11.12</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>11.17</td>\n",
       "      <td>11.188571</td>\n",
       "      <td>11.210000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.07</td>\n",
       "      <td>11.29</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98</th>\n",
       "      <td>1.0</td>\n",
       "      <td>11.11</td>\n",
       "      <td>11.18</td>\n",
       "      <td>long at 11.18</td>\n",
       "      <td>11.18</td>\n",
       "      <td>11.158571</td>\n",
       "      <td>11.173333</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11.03</td>\n",
       "      <td>11.18</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>1.0</td>\n",
       "      <td>11.13</td>\n",
       "      <td>0.00</td>\n",
       "      <td></td>\n",
       "      <td>11.11</td>\n",
       "      <td>11.154286</td>\n",
       "      <td>11.120000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.05</td>\n",
       "      <td>11.23</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    pos  close    pce     trend_info   open        ma2        ma1  sig    low  \\\n",
       "0   0.0   9.80   0.00                  9.72        NaN        NaN  0.0   9.71   \n",
       "1   0.0   9.70   0.00                  9.74        NaN        NaN  0.0   9.58   \n",
       "2   0.0   9.81   0.00                  9.70        NaN   9.770000  0.0   9.66   \n",
       "3   0.0   9.96   0.00                  9.73        NaN   9.823333  0.0   9.70   \n",
       "4   0.0   9.98   0.00                 10.09        NaN   9.916667  0.0   9.92   \n",
       "..  ...    ...    ...            ...    ...        ...        ...  ...    ...   \n",
       "95 -1.0  11.22   0.00                 11.09  11.212857  11.143333  0.0  10.96   \n",
       "96 -1.0  11.29   0.00                 11.19  11.220000  11.206667  0.0  11.02   \n",
       "97 -1.0  11.12   0.00                 11.17  11.188571  11.210000  0.0  11.07   \n",
       "98  1.0  11.11  11.18  long at 11.18  11.18  11.158571  11.173333  2.0  11.03   \n",
       "99  1.0  11.13   0.00                 11.11  11.154286  11.120000  0.0  11.05   \n",
       "\n",
       "     high  trend  \n",
       "0    9.95    0.0  \n",
       "1    9.79    0.0  \n",
       "2    9.82    0.0  \n",
       "3   10.00    0.0  \n",
       "4   10.09    0.0  \n",
       "..    ...    ...  \n",
       "95  11.26   -1.0  \n",
       "96  11.30   -1.0  \n",
       "97  11.29    1.0  \n",
       "98  11.18    1.0  \n",
       "99  11.23   -1.0  \n",
       "\n",
       "[100 rows x 11 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
